package com.oocl.euc.core.maintenance.repository;

import com.oocl.euc.framework.base.persistence.IBaseRepository;
import com.oocl.euc.core.maintenance.model.TeamEndorser;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public interface TeamEndorserRepository extends IBaseRepository<TeamEndorser, Long> {

    @Query(value = "SELECT display_name FROM pcrs_users WHERE STAFF_ID "
            + "IN "
            + "(SELECT STAFF_ID FROM PCRS_TEAM_LIST team_list, PCRS_TEAM_ENDORSERS endorsers "
            + "WHERE team_list.id = endorsers.team_id AND team_id = :teamId)", nativeQuery = true)
    List<String> findDisplayName(@Param("teamId") Long teamId);
}
